﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="products.aspx.cs" validaterequest="false" Inherits="WebApplication.admin.products" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>产品管理</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script src="../scripts/script.js" type="text/javascript"></script>
<script type="text/javascript" src="../scripts/qsl.ui.imagepreview.js"></script>
<script type="text/javascript" src="../scripts/qsl.validate.net.js"></script>
</head>

<body>
<% if (isadd) { %>
<form action="?do=save&id=<%= id %>&start=<%= start %>&limit=<%= limit %>" method="post" enctype="multipart/form-data" class="root form" autocomplete="off">
    <h3>编辑产品信息</h3>
    <div class="item"><label>产品名称：</label><input type="text" class="text" id="name" name="name" runat="server" /></div>
    <div class="item"><label>所属类别：</label><select runat="server" datatextfield="Name" datavaluefield="Id" id="type"></select></div>
    <div class="item">
        <label>产品图片：<br /><br />说明：产品图片<br />宽高比例4:3，<br />最佳尺寸为<br />360*270px</label>
        <div id="pre" class="preview" style="width: 360px; height: 270px"></div>
    </div>
    <div class="item"><label>选择图片：</label><input type="file" class="text" id="file" name="file" runat="server" /></div>
    <div class="item"><label>产品描述：</label><textarea name="intro" id="intro" runat="server"></textarea></div>
    <div class="item"><label>&nbsp;</label><input type="submit" value="保存" /> <input type="button" onclick="history.back()" value="取消" /></div>
</form>

<script type="text/javascript">
CKEDITOR.replace('intro');
var ip = new ImagePreview('pre', 360, 270, { input: 'file' });
if ('<%= file_src %>') ip.setImage('<%= file_src %>');
new FormChecker([
    ['name', '产品名称不能为空'],
    ['type', '产品类别不能为空'],
    //['file', '请选择一张产品图片', function (v) { return !!(ip.src || v) }]
]);
</script>
<% } else { %>
<table border="0" cellpadding="1" cellspacing="1" class="grid">
    <thead>
        <tr>
            <th width="60" style="text-align: center">序号</th>
            <th>名称</th>
            <th width="160">发布时间</th>
            <th width="200">操作</th>
        </tr>
    </thead>
    <tbody>
        <asp:repeater runat="server" id="p_list">
            <itemtemplate>
        <tr>
            <td align="center"><%# DataBinder.Eval(Container.DataItem, "Id") %></td>
            <td><a target="_blank" href="../<%# DataBinder.Eval(Container.DataItem, "GUID") %>.aspx"><%# DataBinder.Eval(Container.DataItem,"Name") %></a></td>
            <td><%# DataBinder.Eval(Container.DataItem, "AddTime") %></td>
            <td>
                <a href="product_images.aspx?pid=<%# DataBinder.Eval(Container.DataItem, "Id") %>&start=<%# start %>&limit=<%# limit %>">管理图片</a>
                <a href="?do=edit&id=<%# DataBinder.Eval(Container.DataItem,"Id") %>&start=<%# start %>&limit=<%# limit %>">编辑</a>
                <a href="?do=delete&id=<%# DataBinder.Eval(Container.DataItem,"Id") %>&start=<%# start %>&limit=<%# limit %>" onclick="return confirm('确定删除?')">删除</a>
            </td>
        </tr>
            </itemtemplate>
        </asp:repeater>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="4">
                <qsl:pager runat="server" limit="10" id="p_pager" />
            </td>
        </tr>
    </tfoot>
</table>
<% } %>
</body>
</html>
